<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=0.5,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no, email=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <!-- 删除苹果默认的工具栏和菜单栏 -->
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <!-- 设置苹果工具栏颜色 -->
    <meta name="format-detection" content="telphone=no, email=no" />
    <!-- 忽略页面中的数字识别为电话，忽略email识别 -->
    <!-- 启用360浏览器的极速模式(webkit) -->
    <meta name="renderer" content="webkit">
    <!-- 避免IE使用兼容模式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
    <meta name="HandheldFriendly" content="true">
    <!-- 微软的老式浏览器 -->
    <meta name="MobileOptimized" content="320">
    <!-- uc强制竖屏 -->
    <meta name="screen-orientation" content="portrait">
    <!-- QQ强制竖屏 -->
    <meta name="x5-orientation" content="portrait">
    <!-- UC强制全屏 -->
    <meta name="full-screen" content="yes">
    <!-- QQ强制全屏 -->
    <meta name="x5-fullscreen" content="true">
    <!-- UC应用模式 -->
    <meta name="browsermode" content="application">
    <!-- QQ应用模式 -->
    <meta name="x5-page-mode" content="app">
    <!-- windows phone 点击无高光 -->
    <meta name="msapplication-tap-highlight" content="no">
    <title>工单管理</title>
    <link rel="stylesheet" href="{{asset('css/reset.css')}}">
    <link rel="stylesheet" href="{{asset('css/main.css')}}">
    <link rel="stylesheet" href="{{asset('css/index.css')}}">
    <link rel="stylesheet" href="{{asset('css/LCalendar.css')}}">
    <link rel="stylesheet" href="{{asset('css/yd_rl.css')}}" />
</head>
<body>
    <!-- 公共头部 -->
    <div class="g2_head-bg">
        <!-- 返回上一层 -->
        <p class="g2_head_goback-bg fl">
            <a href="javascript:history.back(-1)">
                <img src="{{asset('images/xky_icon0-1.png')}}" class="g2_head_goback_icon fl" alt="">
                <span class="g2_head_goback_del fl">返回</span>
            </a>
        </p>
        <p class="ym-tit fl">新增请款</p>
        <span class="g2_head_goback_del fr khxz_color">新增</span>
        <div class="cl"></div>
    </div>
    <div class="g2_head-bg2"></div>
    <ul class="xzsk-bg">
        <form action="" id="formshoukuan">
            {{ csrf_field() }}
        <li class="xzsk_list">
            <p class="xzsk_tit fl">供应商</p>
            <p class="xzsk_del fr">
                <input type="text"  class="gysxz" placeholder="选择供应商" value="">
                <span class="gyslist">
                    @foreach($supplier as $val)
                    <span class="gyslist_xql" myAttr="{{$val->id}}">{{$val->supplier_name}}</span>
                    @endforeach
                </span>
            </p>
            <div class="cl"></div>
        </li>
        <li class="xzsk_list">
            <p class="xzsk_tit fl">账户名称</p>
            <p class="xzsk_del fr">
                <input type="text"  id="zhanghu" class="gysxz" placeholder="选择账户名称" value="">
                <span class="gyslist" id="zhanghulist">
                    
                </span>
            </p>
            <div class="cl"></div>
        </li>
        <li class="xzsk_list">
            <p class="xzsk_tit fl">账户账号</p>
            <p class="xzsk_del1 fr">
                <input type="text" name="funds_zhanghu" id="zhanghao" readonly="readonly" class="gysxz" placeholder="" value="">
            </p>
            <div class="cl"></div>
        </li>
        <li class="xzsk_list">
            <p class="xzsk_tit fl">请款金额</p>
            <p class="xzsk_del1 fr">
                <input type="text" name="funds_money" class="gysxz" placeholder="请输入请款金额" value="">
            </p>
            <div class="cl"></div>
        </li>
        <li class="xzsk_list sxlist-bg">
            <p class="xzsk_tit fl">上传凭证</p>
            <p class="xzsk_del2 fr">
                <input type="file" name="photo" class="gysxz" id="up_img_WU_FILE_0" style="width:100%;opacity:0;" value="">
            </p>
            <img src="" class="pzimg fr" id="imgShow_WU_FILE_0" alt="">
            <div class="cl"></div>
        </li>
        <li class="xzsk_list">
            <p class="xzsk_tit fl" style="height:14vw;">备注信息</p>
            <textarea name="funds_beizhu" id="" class="bzx2 fr" style="resize:none;"></textarea>
            <div class="cl"></div>
        </li>
        <input type="hidden" name="funds_dealid" value="{{$funds_dealid}}">
        <input type="hidden" name="funds_orderid" value="{{$funds_orderid}}">
        <input type="hidden" name="funds_userid" value="{{$funds_userid}}">
        <input type="hidden" name="funds_zhtype" id="funds_zhtype" value="">
        <input type="hidden" name="funds_zhanghumingcheng" id="funds_zhanghumingcheng" value="">
        <input type="hidden" name="funds_kaihu" id="kaihuhang" value="">
        <input type="hidden" name="funds_type" id="funds_type" value="">
        <input type="hidden" name="funds_typename" id="funds_typename" value="">
        <input type="hidden" name="funds_gongyingshang" id="funds_gongyingshang" value="">
        <input type="hidden" name="funds_name" value="{{$funds_name}}">
        @if($deal->deal_jiesuanstatue==1)
        <input type="text" name="" class="skxzcx_btn fl" value="撤 销">
        <input type="text" id="tijiao" class="skxzqd_btn fr" value="确 定">
        @endif
        <div class="cl"></div>
        </form>
    </ul>


    <!-- loading 小圆圈 -->
    <div class="z2_loading-bg" style="width:100%;height:100%;background:rgba(255,255,255,0.6);position:fixed;;left:0;top:0;display:none;">
        <img src="{{asset('images/loading1.gif')}}" style="width:10%;position:fixed;left:0;right:0;top:0;bottom:0;margin:auto;" alt="">
    </div>
    <!-- loadning对号 -->
    <div class="duihao" style="width:100%;height:100%;position:fixed;;left:0;top:0;display:none;">
        <img src="{{asset('images/duihao.png')}}" style="width:10%;position:fixed;left:0;right:0;top:0;bottom:0;margin:auto;" alt="">
    </div>
    <!-- 下拉框遮罩-->
    <div class="xlz2-bg" style="width:100%;height:100%;position:fixed;left:0;top:0;background:transparent;z-index:-1;"></div>

    <script src="{{asset('js/jquery.min.js')}}"></script>
    <script src="{{asset('js/fastclick.min.js')}}"></script>
    <script src="{{asset('js/sc.js')}}" type="text/javascript" charset="utf-8"></script>
</body>
    <script src="{{asset('js/index.js')}}" type="text/javascript" charset="utf-8"></script>
    <script>
         // 表单提交上传添加
        $("#tijiao").click(function(){
            if($("input[name='funds_gongyingshang']").val()==''){
                $("#tishi").html('供应商必须选择');
                $("#tishi").stop(true, true).fadeIn('fast');
                $("#tishi").fadeOut(1500);
            }else if($("input[name='funds_zhanghumingcheng']").val()==''){
                $("#tishi").html('账户名称必须选择');
                $("#tishi").stop(true, true).fadeIn('fast');
                $("#tishi").fadeOut(1500);
            }else if($("input[name='funds_zhanghao']").val()==''){
                $("#tishi").html('账号必须输入');
                $("#tishi").stop(true, true).fadeIn('fast');
                $("#tishi").fadeOut(1500);
            }else if($("input[name='funds_money']").val()==''){
                $("#tishi").html('请款金额必须输入');
                $("#tishi").stop(true, true).fadeIn('fast');
                $("#tishi").fadeOut(1500);
            }else if($("input[name='funds_beizhu']").val()==''){
                $("#tishi").html('请款备注必须输入');
                $("#tishi").stop(true, true).fadeIn('fast');
                $("#tishi").fadeOut(1500);
            }else{
                $('.z2_loading-bg').show();
                var formData = new FormData($("#formshoukuan")[0]);
                $.ajax({
                    url: "{{url('qingkuantianjia')}}" ,
                    type: 'POST',
                    data: formData,
                    async: false,
                    cache: false,
                    contentType: false,
                    processData: false,
                    success: function (returndata) {
                        alert(returndata);
                       if(returndata=="false"){
                            $('.z2_loading-bg').hide();
                            alert("添加失败");
                            
                       }else if(returndata=="dianzi"){
                            $('.z2_loading-bg').hide();
                            $("#tishi").html('此订单需垫资请等待总经理审批');
                            $("#tishi").stop(true, true).fadeIn('fast');
                            $("#tishi").fadeOut(1500);
                            window.location.href=document.referrer;
                       }else{
                            window.location.href=document.referrer;
                       }
                    },
                    error: function (returndata) {
                        $('.z2_loading-bg').hide();
                        alert("添加失败");
                    }
                });
            }
        });
        $(function () {
            FastClick.attach(document.body);
        });

        // 收款新增下拉框
        $('.gysxz').click(function(){
            $(this).parent().children().eq(1).stop(true).show(500);
        })
        $('.gyslist_xql').click(function(){
            var id=$(this).attr('myAttr');
            $.ajax({
                url:"{{url('deal/zhanghu')}}",
                type:'get', //GET
                async:false,    //或false,是否异步
                data:{'id':id},
                dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                success:function(data){ 
                    if(data!=''){
                        var html="";
                        $.each(data,function(i,item){
                            html+="<span class=\"gyslist_xql\" myAttr=\""+item.id+"\">"+item.name+"</span>";
                    　　});
                        $("#zhanghulist").html(html);
                        $("#zhanghulist span").click(function(){
                            var id=$(this).attr('myAttr');
                            $("#funds_zhtype").val(id);
                            $.ajax({
                                url:"{{url('deal/qkzhanghao')}}",
                                type:'get', //GET
                                async:false,    //或false,是否异步
                                data:{'id':id},
                                dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                                success:function(data){
                                    $("#zhanghao").val(data.zhanghao);
                                    $("#kaihuhang").val(data.kaihuhang);
                                    $("#funds_zhanghumingcheng").val(data.funds_zhanghumingcheng);
                                    $("#funds_type").val(data.funds_type);
                                    // $("#fangshi").val(data.fangshi);
                                }, 
                            })
                            $(this).parent().parent().children().eq(0).val($(this).html());
                            $('.gyslist').hide();
                        })
                    }
                }, 
            })
            $(this).parent().parent().children().eq(0).val($(this).html());
            $("#funds_typename").val($(this).html());
            $("#funds_gongyingshang").val($(this).attr('myAttr'));
            $('.gyslist').hide();
        })

    </script>
</html>